package com.myapi.ModelPoker;

import java.util.ArrayList;

public abstract class PokerGame  {
	
	private double bigBlind;
	private double smallBlind;
	private double ante;

	private static PokerStyleFactory factory;
        private static PokerGame pokerGame;
        private static String gameType;
        private static final String CASH = "Cash";  //the two types of poker game
        private static final String TOURNAMENT = "Cash";
	
	protected PokerGame() {  //needs to be singleton
			
            setSmallBlind(0);
            setBigBlind(0);
            setAnte(0);
	}
        
        public static PokerGame getPokerGame() {
            if(pokerGame == null) {
                if(getGameType().equals(CASH))
                    pokerGame = new CashGame();
                else if(getGameType().equals(TOURNAMENT))
                    pokerGame = new TournamentGame();
            }
            return pokerGame;
	}
        
        public static void setGameType(String type) {
            if(type.equals("-c"))
                gameType = CASH;
            else
                gameType = TOURNAMENT;
        }
        
        public static String getGameType() {
            return gameType;
        }
	
	public double getAnte() {
		return ante;
	}
	
	public void setAnte(double ante) {
		this.ante = ante;
	}
	
	public double getSmallBlind() {
		return smallBlind;
	}
	
	public void setSmallBlind(double sb) {
		smallBlind = sb;
	}
	
	public double getBigBlind() {
		return bigBlind;
	}
	
	public void setBigBlind(double bb) {
		bigBlind = bb;
	}
	
	public PokerStyleFactory getPokerStyleFactory() {
		return factory;
	}
	
	public static void setPokerStyle(String style) {
            if(style.equals("-d"))
                factory = new DrawFactory();
            else
                factory = new HoldEmFactory();
	}
    public abstract void startGame();

    public abstract boolean addPlayer(String name,String id,double cash);
    public abstract boolean removePlayer(String id);
	
    public static void main(String [] arg){
    	createPokerCashGame();
    }
	public static PokerGame createPokerCashGame() {
            setGameType("-c");
            setPokerStyle("-h");
            PokerGame game = getPokerGame();            
	  /* gui = TableGui.getTableGui();
            gui.setPokerGame(game);
            game.addPlayer("Pierre","P");
            game.addPlayer("Flordnt","F");
            game.addPlayer("Flsrant","n");
            game.addPlayer("Fltrant","b");
            game.startGame();
            gui.makeBet(10, false);
            gui.makeBet(10, false);
            gui.makeBet(10, false);
            gui.makeBet(14, false);
            gui.makeBet(14, false);
            gui.makeBet(14, false);
            gui.makeBet(14, false);
            //flop
            gui.makeBet(2, false);
            gui.makeBet(2, false);
            gui.makeBet(2, false);
            gui.makeBet(2, false);
           // turn
            gui.makeBet(1, false);
            gui.makeBet(1, false);
            gui.makeBet(1, false);
            gui.makeBet(1, false);
            //river
            gui.makeBet(2, false);
            gui.makeBet(2, false);
            gui.makeBet(2, false);
            gui.makeBet(2, false);
            */
            return game;
            
	}

	
}
